<template>
  <Form :ref="user" :model="user" label-position="left" :label-width="100">
    <FormItem label="用户名">
      <Input v-model="user.username"></Input>
    </FormItem>
    <FormItem label="密码">
      <Input v-model="user.password"></Input>
    </FormItem>
    <FormItem>
      <Button type="primary" @click="login()">Submit</Button>
      <Button @click="handleReset('user')" style="margin-left: 8px">Reset</Button>
    </FormItem>
  </Form>
</template>
<script>
export default {
  data () {
    return {
      user: {
        username: '闫冬',
        password: ''
      }
    }
  },
  methods: {
    login () {
      // this.getlist();
      this.actionLogin();
    },
    actionLogin () {
      this.axios({
        method: 'post',
        data: this.user,
        url: '/login'
      }).then(function (resp) {
        console.log(resp.data)
      }).catch(resp => {
        console.log('请求失败: ' + resp.status + ', ' + resp.statusText)
      })
    },
    getlist () {
      this.axios({
        method: 'get',
        url: '/idea'
      }).then(function (resp) {
        console.log(resp.data)
      }).catch(resp => {
        console.log('请求失败: ' + resp.status + ', ' + resp.statusText)
      })
    },
    reset (name) {
      this.$refs[name].resetFields()
    }
  }
}
</script>
<style scoped>
</style>
